package cn.ekuma.epos.datalogic.define.dao.kuaidi;

import com.openbravo.bean.infobean.UserInfo;
import com.openbravo.bean.kuaidi.KuaiDi;
import com.openbravo.data.basic.BasicException;
import com.openbravo.data.loader.DataRead;
import com.openbravo.data.loader.DataWrite;
import com.openbravo.data.loader.Datas;
import com.openbravo.data.loader.I_Session;
import com.openbravo.data.loader.TableDefinition;
import com.openbravo.data.model.Field;
import com.openbravo.format.Formats;

import cn.ekuma.data.dao.BaseDAO;
import cn.ekuma.epos.db.table.kuaidi.I_KuaiDi;


public class KuaiDiDAO extends BaseDAO<KuaiDi>{

	public KuaiDiDAO(I_Session s) {
		super(s);
		
	}

	@Override
	public TableDefinition getTable() {
		return new TableDefinition(s,
                "KUAIDI",
                new Field[]{
                     new Field(I_KuaiDi.ID,Datas.STRING,Formats.STRING),
                     new Field(I_KuaiDi.MINGCHENG,Datas.STRING,Formats.STRING),
                     new Field(I_KuaiDi.DANHAO,Datas.STRING,Formats.STRING,UserInfo.class),
                     new Field(I_KuaiDi.DIANHUA,Datas.STRING,Formats.STRING) ,
                     new Field(I_KuaiDi.ZHUANGTAI,Datas.STRING,Formats.STRING),
                     new Field(I_KuaiDi.CREATETIME,Datas.TIMESTAMP,Formats.TIMESTAMP),
                     new Field(I_KuaiDi.FINALTIME,Datas.TIMESTAMP,Formats.TIMESTAMP),
                     new Field(I_KuaiDi.USERID,Datas.STRING,Formats.STRING)
                    },
                new int[]{0});
	}

	@Override
	public void writeInsertValues(DataWrite dp, KuaiDi obj)
			throws BasicException {
		dp.setString(0, obj.getKey());
		dp.setString(1, obj.getMingCheng());
		dp.setString(2,obj.getDanHao());
		dp.setString(3,obj.getDianHua());
		dp.setString(4,obj.getZhuangTai());
		dp.setTimestamp(5,obj.getCreateTime());
		dp.setTimestamp(6, obj.getFinalTime());
		dp.setString(7,obj.getUserId());
		
	}

	@Override
	public Class getSuportClass() {
		
		return KuaiDi.class;
	}

	@Override
	public KuaiDi readValues(DataRead dr, KuaiDi obj) throws BasicException {
		if(obj==null)
			obj=new KuaiDi();
		obj.setKey(dr.getString(0));
		obj.setMingCheng(dr.getString(1));
		obj.setDanHao(dr.getString(2));
		obj.setDianHua(dr.getString(3));
		obj.setZhuangTai(dr.getString(4));
		obj.setCreateTime(dr.getTimestamp(5));
		obj.setFinalTime(dr.getTimestamp(6));
		return obj;
	}

}
